<?php include Doo::conf()->SITE_PATH .  Doo::conf()->PROTECTED_FOLDER . "viewc//menu.php"; ?>
<div id='main-site-globalbo-moduleSpace-cms-content'>
  <?php foreach($data['contents'] as $k1=>$v1): ?>
  <div class='main-site-globalbo-moduleSpace-cms-content-edit'>
    <div class='main-site-globalbo-moduleSpace-cms-content-edit-title'><?php echo $v1->cnt_real_name; ?></div>
    <textarea rows="10" cols="70" class='textarea-content' name="text_area_<?php echo $v1->cnt_id; ?>"><?php echo $v1->cnt_content; ?></textarea>
    <input type='hidden' name='id_content' value="<?php echo $v1->cnt_id; ?>" class='id_content_value'>
    <div class='main-site-globalbo-moduleSpace-cms-content-edit-ajax_response'></div>
    <input type='button' value='Enregistrer' class='personal-button fright'>
  </div>
  <?php endforeach; ?>
</div>

<script type="text/javascript">
$('.main-site-globalbo-moduleSpace-cms-content-edit-ajax_response').hide();
$(document).ready(function(){  
  $(".personal-button").click(function(){
    if(confirm('Êtes-vous sûr de vouloir enregistrer la modfication ?')){
      var id = $(this).siblings(".id_content_value").val();
      var content = tinyMCE.get('text_area_'+id).getContent();
      var data = "id_content="+id+"&content="+content;
      var response_zone = $(this).siblings(".main-site-globalbo-moduleSpace-cms-content-edit-ajax_response"); 
      var url="<?php echo $data['baseurl']; ?>admin/frbCms/frbCms_MainController/index";
      $.ajax({
        urlApp: url,
        type: 'POST',
        cache: false,
        data: data,
        success: function(html){
          if(html=="true"){
            response_zone.attr('class', 'main-site-globalbo-moduleSpace-cms-content-edit-ajax_response gresponse');
            response_zone.html('Modification enregistrée');
            response_zone.fadeIn('slow');
          }else{
            response_zone.attr('class', 'main-site-globalbo-moduleSpace-cms-content-edit-ajax_response bresponse');
            response_zone.html("Erreur lors de l'enregistrement. Aucune modification effectuée");
            response_zone.fadeIn('slow');
          }
        }
      });  
    }
  });
});
</script>

<script type="text/javascript" src="<?php echo $data['baseurl']; ?>global/js/globalbo/tiny_mce/tiny_mce.js" ></script >
<script type="text/javascript">
tinyMCE.init({
        mode : "textareas",
        language : "en",
        entity_encoding : 'false',
        theme : "simple"   //(n.b. no trailing comma, this will be critical as you experiment later)
});
</script>
